package ltd.flyweight.liquibasehelper.module.jzgk.dao.entity;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import ltd.flyweight.liquibasehelper.core.dao.entity.TenantEntity;

import java.io.Serial;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * 字典类型对象 sys_dict_type
 *
 * @author 周立山
 * @date 2024-06-04
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "sys_dict_type", autoResultMap = true)
public class JzgkSysDictTypeEntity extends TenantEntity {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 字典主键
     */
    @TableId(value = "dict_id")
    private Long dictId;

    /**
     * 字典名称
     */
    private String dictName;

    /**
     * 字典类型
     */
    private String dictType;

    /**
     * 备注
     */
    private String remark;

    /**
     * 状态（0正常 1停用）
     */
    private String status;

    /**
     * 1:系统字典，2：下发至各单位
     */
    private String useType;

    @TableField(exist = false)
    private List<JzgkSysDictDataEntity> dictDataList;

    public Map<String, JzgkSysDictDataEntity> getDictDataMapKeyWithDictValue() {
        return CollectionUtil.toMap(dictDataList, new LinkedHashMap<>(), JzgkSysDictDataEntity::getDictValue);
    }

    @TableField(exist = false)
    private List<JzgkSysDictTypeExtensionEntity> extensionList;

    public Map<String, JzgkSysDictTypeExtensionEntity> getExtensionMapKeyWithDataKey() {
        return CollectionUtil.toMap(extensionList, new LinkedHashMap<>(), JzgkSysDictTypeExtensionEntity::getDataKey);
    }

}
